<?php

	class AppController extends Controller
	{
		var $components = array('Auth');
		
		function beforeFilter()
		{
			Security::setHash('md5');

			//$this->Session->write("current_client_id", "1");
			// need to use model other than user with Auth Component
			
			$this->Auth->userModel = 'Client';
			$this->Auth->loginAction = '/clients/login';
			
			$this->Auth->loginRedirect = array('controller' => 'clients', 'action' => 'index');
			$this->Auth->logoutRedirect = array('controller' => 'clients', 'action' => 'index');
			
			$this->Auth->allow('signup', 'confirm', 'check_email');
			
			$this->Auth->authorize = 'controller';
			
			$this->Auth->userScope = array('Client.confirmed' => '1');
			
			$this->Session->write("current_client_id", $this->Auth->user('id'));
			//$this->set('current_client_id', $this->Auth->user('id'));
			$this->set('loggedIn', $this->Auth->user('id'));
		}
		
		function isAuthorized()
		{
			return true;
		}
	}

?>
